package com.weilx959.spt.app.plugin;

import com.weilx959.spt.app.constants.AppConstants;
import com.weilx959.spt.app.controller.SettingViewController;
import com.weilx959.spt.core.LanguageContext;
import com.weilx959.spt.core.constants.CommonConstants;
import com.weilx959.spt.core.interfaces.Controller;
import com.weilx959.spt.core.interfaces.SPTPlugin;
import com.weilx959.spt.core.utils.FXMLUtil;
import javafx.scene.Node;

import java.util.Optional;
import java.util.ResourceBundle;

public class SettingPluginImpl implements SPTPlugin {
    private final SettingViewController controller;

    private final ResourceBundle bundle;

    public SettingPluginImpl() {
        bundle = ResourceBundle.getBundle(AppConstants.LANGUAGE_BASE_NAME,
            Optional.ofNullable(LanguageContext.get()).orElse(CommonConstants.DEFAULT_LANGUAGE).getLocale());
        controller = FXMLUtil.getController("com/weilx959/spt/app/setting-view.fxml", bundle);
    }

    @Override
    public String getID() {
        return "1c2b881d-dbfa-4bf4-8b17-c59431570411";
    }

    @Override
    public String getName() {
        return bundle.getString("app.setting.name");
    }

    @Override
    public String getDescription() {
        return bundle.getString("app.setting.description");
    }

    @Override
    public String getIconStyle() {
        return "setting";
    }

    @Override
    public String getVersion() {
        return bundle.getString("app.setting.version");
    }

    @Override
    public String getAuthor() {
        return bundle.getString("app.setting.author");
    }

    @Override
    public Controller getController() {
        return controller;
    }

    @Override
    public Node getView() {
        return controller.getRootPane();
    }

    @Override
    public Integer getOrder() {
        return 1;
    }
}
